/**
 * 医疗服务质询初始化模块，提供医疗服务编辑页面初始化组件功能
 * 
 * @Date: 2016-1-25
 * @author: Jackson wang
 * @version: 1.0
 * @since: 1.0
 */

define(["jquery","sysmanMain","dateUtil","bsButtonEvent","btnServ"],
		function($,sysmanMain,dateUtil,bsButtonEvent,btnServ) {
			
		'use strict';
		var rootid = 'panel-duties-statistic';
		var bizcode = 'dutiesStatistic';
		var public_method ={
			
			
			
			/**
			 * 设置模块点击页面
			 * @param _options.record 列表选中行
			 * @param _options.grid 页面form对象
			 * @param _options.rootId 页面根节点
			 */
			clickCell:function(index,field,value){
				
				var _config = sysmanMain.getCurrentModuConfig()
				
				if(!value  || value<=0){
					_config.clickValue = 0
					sysmanMain.setCurrentModuConfig(_config)
					return 
				}else{
					_config.clickValue = 1
					sysmanMain.setCurrentModuConfig(_config)
				}
				var _param ={}
				if(field && (field!=='sumary_matter')){
					_param.issue = field
				}				
				
				_config.clickParam = _param				
				sysmanMain.setCurrentModuConfig(_config)
				
			},
			
			/**
			 * 设置模块点击参数页面
			 * @param _options.record 列表选中行
			 * @param _options.grid 页面form对象
			 * @param _options.rootId 页面根节点
			 */
			clickRow:function(index,row){
				if(window.console){
					console.log('index:' + index)
					console.log('row.dept_name:' + row.dept_name)					
				}
				var _config = sysmanMain.getCurrentModuConfig()	
				
				//点击为0cell
				if(_config.clickValue <= 0){
					return 
				}
				var _param = {sqks:row.dept_name,over_days_ge:50,sxzt:'在办'}
				if (_config.clickParam){					
					$.extend(_config.clickParam,_param) 
				}else{
					_config.clickParam = _param
				}
				sysmanMain.setCurrentModuConfig(_config)
				
				var initQueryParams = {condition:_config.clickParam}
				
				
				sysmanMain.setModuConf('dutiesInfo',{initQueryParams:initQueryParams})
				
				sysmanMain.dutiesInfoSelect()
			}	
			
			,
			
			initElement:function(){
				var btn = $('#'+rootid + ' .function-btn')
				$(btn).bind('click', private_method.function_btn_listenner)	
			}
		};	
		
		var private_method = {
			
			fn_export : function(e){
				if(window.console){
					console.log('  ... export loading ...')
				}
				
				var _url = '/'+sysmanMain.getRootPath()+'/'+bizcode+'/query/exportExcel.action';
	    		var _param = {};
	    		bsButtonEvent.exportAll({url:_url,queryParam:_param});
	    		$(e.currentTarget).linkbutton('enable');
			},
			
			function_btn_listenner:function(e){
				btnServ.applyButton({buttonEvt:e,buttonConfig:{'导出' :	private_method.fn_export}})
			}
		};
		
		return public_method;
			
})